/* === LICENSE INFO ===
 * This source file is subject to the GPLv3 license that is bundled with this
 * package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl.txt
 * === end of LICENSE INFO === */

/*==============================================================================
  File Name   : LogWriter.cpp
  Description : Definition for LogWriter class in GLog module.

  Created on  : 2009-10-09
  Updated on  : 2011-01-30
  Updated by  : Lee Shiou Ming

  Cautions    : (important notes)
  ============================================================================*/

//------------------------------------------------------------------------------
//-- INCLUDES & DEFINES
//------------------------------------------------------------------------------
#include "LogWriter.hpp"
#include "GDateTime/GDateTime.hpp"

using namespace gUtil::GLog;


//------------------------------------------------------------------------------
//-- INITIALIZATIONS
//------------------------------------------------------------------------------


//------------------------------------------------------------------------------
//-- FUNCTION IMPLEMENTATIONS
//------------------------------------------------------------------------------
std::string LogWriter::formatLogMessage(const std::string& _logMessage,
        const std::string& _logLevelString,
        const GDateTime::ptime& _log_msg_time)
{
    std::string formattedLogMessage;

    formattedLogMessage = "[" + GDateTime::getDateTimeString(
            _log_msg_time, GDateTime::PRECISION_MILLESECOND) +
            "]";
    formattedLogMessage += "[" + _logLevelString + "] ";
    formattedLogMessage += _logMessage;
    formattedLogMessage += "\n";

    return formattedLogMessage;
}
